<?php
namespace app\achievement\controller;

use app\common\model\AreasModel;
use app\common\model\CustomerLabelModel;
use app\common\model\CustomerModel;
use app\common\model\FollowModel;
use app\common\model\OaWorkersModel;

/**
 * Class Test
 * @package app\achievement\controller
 */
class Configure extends Base
{
    // 初始化构造方法
    public function __construct()
    {
        parent::__construct();

    }
    // 结算配置
    public function index()
    {
        $is_admin = session($this->set['db_name'].'is_admin');
        if (!$is_admin){
            $rule = session($this->set['db_name'] . 'rule');
            //限制
            $del = 0;
            if (!empty($rule)){
                $rule = explode(',',$rule);
                if (in_array('332',$rule)){
                    $del = 1;
                }
            }
        }else{
            $del = 1;
        }

        $this->assign('del',$del);
        return $this->fetch();
    }
    // 编辑配置
    public function edit()
    {
        $id = input('id');
        $this->assign('id',$id);
        return $this->fetch();
    }
    // 添加配置
    public function add()
    {
        return $this->fetch();
    }

    /**
     * [add_config 添加配置]

     */
    public function add_config()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $config = new ConfigModel();
            $flag = $this->cfg->insertConfig($param);
            cache('db_config_data',null);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        return $this->fetch();
    }

}
